/*
 * @Author: szx
 * @Date: 2022-03-26 14:13:48
 * @LastEditTime: 2022-03-26 14:25:30
 * @Description:
 * @FilePath: \leetcode\400-499\474\474_2.js
 */
/**
 * @param {string[]} strs
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var findMaxForm = function (strs, m, n) {
    const dp = new Array(m + 1).fill(0).map(() => new Array(n + 1).fill(0));
    for (let str of strs) {
        let zeroNum = 0,
            oneNum = 0;
        for (let ch of str) {
            if (ch == '0') zeroNum++;
            else oneNum++;
        }
        for (let i = m; i >= zeroNum; i--) {
            for (let j = n; j >= oneNum; j--) {
                dp[i][j] = Math.max(dp[i][j], dp[i - zeroNum][j - oneNum] + 1);
            }
        }
    }
    return dp[m][n];
};
